<!-- 搜索表单 -->
<template>
  <ele-card :body-style="{ paddingBottom: '2px' }">
    <el-form label-width="72px" @keyup.enter="search" inline>
      <el-form-item label="报名状态">
        <el-radio-group v-model="form.status" @change="search">
          <el-radio-button label="">全部</el-radio-button>
          <el-radio-button :label="1">正常</el-radio-button>
          <el-radio-button :label="0">退定</el-radio-button>
        </el-radio-group>
      </el-form-item>

      <br />
      <el-form-item label="会员姓名">
        <el-input clearable v-model.trim="form.realname" placeholder="请输入" />
      </el-form-item>

      <el-form-item label="联系电话">
        <el-input clearable v-model.trim="form.tel" placeholder="请输入" />
      </el-form-item>

      <el-form-item label-width="16px">
        <el-button type="primary" @click="search">查询报名记录</el-button>
        <el-button @click="reset">重置</el-button>
      </el-form-item>
    </el-form>
  </ele-card>
</template>

<script setup>
  import { useFormData } from '@/utils/use-form-data';
  const emit = defineEmits(['search']);

  /** 表单数据 */
  const [form, resetFields] = useFormData({
    tel: '',
    status: 1,
    username: ''
  });

  /** 搜索 */
  const search = () => {
    console.log(form);
    emit('search', { ...form });
  };

  defineExpose({
    reset: () => {
      resetFields();
      search();
    }
  });

  /**  重置 */
  const reset = () => {
    resetFields();
    search();
  };
</script>
